package com.study;

public class Graphics {
    int width;
    int height;
    int radius;
    private double PI = 3.14;
    private static String shape;

    public Graphics(){};
    public Graphics(int[] arr) {
        if (arr.length == 2) {
            this.width = arr[0];
            this.height = arr[1];
            this.shape = "矩形";
        } else {
            this.radius = arr[0];
            this.shape = "圆";
        }
    }

    public String getShape() {
        return this.shape;
    }

    public double perimeter() {
        return (this.shape == "矩形" ? (this.width + this.height) * 2 : 2 * this.PI * this.radius);
    }

    public double area() {
        return (this.shape == "矩形" ? this.width * this.height : this.PI * Math.sqrt(this.radius));
    }


}
